package com.kudian.restful.job;

import com.kudian.common.persistence.ResultObj;
import com.kudian.common.utils.DateUtils;
import com.kudian.common.utils.JsonUtils;
import com.kudian.restful.entity.AccountStatement;
import com.kudian.restful.service.AccountStatementService;
import com.kudian.restful.service.OrderService;
import com.kudian.restful.vo.accountstatement.AccountStatementVO;
import com.kudian.restful.vo.order.JobReceivingOrderVO;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Administrator on 2016/8/9.
 */
public class ASQuartzJob {
    private static Logger log = Logger.getLogger(ASQuartzJob.class.getName());

    @Autowired
    private OrderService orderService;

    @Autowired
    private AccountStatementService accountStatementService;

    public void work() {
        log.info("ASQuartzJob的任务调度！！！");
        AccountStatementVO vo = new AccountStatementVO();
        // 3天前 其实是两天
        String twoBefore = DateUtils.getBeforeDate(DateUtils.getSysTimestamp().getTime(), 24 * 3 * 60 * 60 * 1000L);
        vo.setAsDay(twoBefore);
        ResultObj retVo = accountStatementService.add(vo);
        log.info(JsonUtils.toJson(retVo));
        log.info("ASQuartzJob的任务调度结束！！！！！！");
    }

    public static void main(String[] args) {
        String oneBefore = DateUtils.getBeforeDate(DateUtils.getSysTimestamp().getTime(), 24 * 2 * 60 * 60 * 1000L);
        System.out.println(oneBefore);
    }
}
